﻿
namespace Membership.Library.Web
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Data;
    using System.Linq;
    using System.ServiceModel.DomainServices.EntityFramework;
    using System.ServiceModel.DomainServices.Hosting;
    using System.ServiceModel.DomainServices.Server;
    
    
    // Implements application logic using the MembershipEntities context.
    // TODO: Add your application logic to these methods or in additional methods.
    // TODO: Wire up authentication (Windows/ASP.NET Forms) and uncomment the following to disable anonymous access
    // Also consider adding roles to restrict access as appropriate.
    // [RequiresAuthentication]
    [EnableClientAccess()]
    public partial class MembershipDomainService : LinqToEntitiesDomainService<MembershipEntities>
    {
        
        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'BusinessPara' query.
        public IQueryable<BusinessPara> GetBusinessPara()
        {
            return this.ObjectContext.BusinessPara;
        }
        
        public void InsertBusinessPara(BusinessPara businessPara)
        {
            if ((businessPara.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(businessPara, EntityState.Added);
            }
            else
            {
                this.ObjectContext.BusinessPara.AddObject(businessPara);
            }
        }
        
        public void UpdateBusinessPara(BusinessPara currentBusinessPara)
        {
            this.ObjectContext.BusinessPara.AttachAsModified(currentBusinessPara, this.ChangeSet.GetOriginal(currentBusinessPara));
        }
        
        public void DeleteBusinessPara(BusinessPara businessPara)
        {
            if ((businessPara.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(businessPara, EntityState.Deleted);
            }
            else
            {
                this.ObjectContext.BusinessPara.Attach(businessPara);
                this.ObjectContext.BusinessPara.DeleteObject(businessPara);
            }
        }
        
        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'Employee' query.
        public IQueryable<Employee> GetEmployee()
        {
            return this.ObjectContext.Employee;
        }
        
        public void InsertEmployee(Employee employee)
        {
            if ((employee.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(employee, EntityState.Added);
            }
            else
            {
                this.ObjectContext.Employee.AddObject(employee);
            }
        }
        
        public void UpdateEmployee(Employee currentEmployee)
        {
            this.ObjectContext.Employee.AttachAsModified(currentEmployee, this.ChangeSet.GetOriginal(currentEmployee));
        }
        
        public void DeleteEmployee(Employee employee)
        {
            if ((employee.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(employee, EntityState.Deleted);
            }
            else
            {
                this.ObjectContext.Employee.Attach(employee);
                this.ObjectContext.Employee.DeleteObject(employee);
            }
        }
        
        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'Function' query.
        public IQueryable<Function> GetFunction()
        {
            return this.ObjectContext.Function;
        }
        
        public void InsertFunction(Function function)
        {
            if ((function.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(function, EntityState.Added);
            }
            else
            {
                this.ObjectContext.Function.AddObject(function);
            }
        }
        
        public void UpdateFunction(Function currentFunction)
        {
            this.ObjectContext.Function.AttachAsModified(currentFunction, this.ChangeSet.GetOriginal(currentFunction));
        }
        
        public void DeleteFunction(Function function)
        {
            if ((function.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(function, EntityState.Deleted);
            }
            else
            {
                this.ObjectContext.Function.Attach(function);
                this.ObjectContext.Function.DeleteObject(function);
            }
        }
        
        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'SystemLog' query.
        public IQueryable<SystemLog> GetSystemLog()
        {
            return this.ObjectContext.SystemLog;
        }
        
        public void InsertSystemLog(SystemLog systemLog)
        {
            if ((systemLog.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(systemLog, EntityState.Added);
            }
            else
            {
                this.ObjectContext.SystemLog.AddObject(systemLog);
            }
        }
        
        public void UpdateSystemLog(SystemLog currentSystemLog)
        {
            this.ObjectContext.SystemLog.AttachAsModified(currentSystemLog, this.ChangeSet.GetOriginal(currentSystemLog));
        }
        
        public void DeleteSystemLog(SystemLog systemLog)
        {
            if ((systemLog.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(systemLog, EntityState.Deleted);
            }
            else
            {
                this.ObjectContext.SystemLog.Attach(systemLog);
                this.ObjectContext.SystemLog.DeleteObject(systemLog);
            }
        }
    }
}


